package progeny;

public class Chromosome {
	
	Allele[] alleles;
	
	public Chromosome(Allele[] alleles){
		this.alleles = alleles;
	}
	
	public HalfChromosome getHalf(){
		Gene[] g = new Gene[alleles.length];
		for (int i = 0; i < g.length; i++)
			g[i] = alleles[i].getRandom();
		return new HalfChromosome(g);
	}
	
	public static Chromosome getChromosome(HalfChromosome a, HalfChromosome b){
		if (a.canMerge(b))return new Chromosome(a.merge(b));
		return null;
	}
	
	public Allele[] getAlleles(){
		return alleles;
	}
	
	public String toString(){
		String result = "";
		for (Allele a: alleles)result+=a.toString()+",";
		return result.substring(0,result.length()-1);
	}
	
	public String getPhenotypes(){
		String result = "";
		for (Allele a: alleles) result += a.getDominantPhenotype()+" ";
		return result;
	}
}
